package com.zhiyun.test.demo.page;

import com.zhiyun.test.base.element.BaseElement;
import com.zhiyun.test.base.page.BasePage;
import com.zhiyun.test.base.util.PropUtil;
import org.openqa.selenium.WebDriver;

import java.util.Objects;

/**
 * Created by user on 2019-5-27.
 */
public class LoginPage extends BasePage{
  private BaseElement baseElement;
  public LoginPage(WebDriver webDriver) {
    super(webDriver);
    baseElement = new BaseElement(webDriver);
  }

  public void setUserName(String username) {
    baseElement.sendKeys("username",username);
  }

  public void setPassword(String password) {
    baseElement.sendKeys("password",password);
  }

  public void clickLoginBtn() {
    baseElement.click("loginBtn");
  }

  public boolean checkSuccess() {
    Boolean success = false;
    try {
      success = Objects.equals(PropUtil.getProp("site.prop","successText"),
        baseElement.getElement("success").getText());
    }catch (Exception e){

    }
    return success;
  }
}
